<template>
  <div className="document-item">
    <div className="document-item__content">
      <div class="document-item__content-wrapped">
        <div class="document-item__content-title">
          {{ data.name }}
        </div>
        <div class="document-item__content-author">作者：{{ data.author }}</div>
        <div class="document-item__content-doc">
          1.主动学习糖尿病知识。会识别糖尿病的可主动学习糖尿病知识。会识别糖尿病的可主动学习糖尿病知识。会识别糖尿病的可
        </div>
      </div>

      <div class="document-item__content-operate">
        <div class="left">
          <LikeLabel :count="data.likecount" />
          <CollectLabel :count="data.collectcount" />
        </div>
        <div class="right">
          <ViewLabel :count="data.viewcount" />
        </div>
      </div>
    </div>
    <div v-if="data.banner" class="banner-wrapper">
      <image :src="data.banner" mode="widthFix" class="document-item__banner" />
    </div>
  </div>
</template>

<script lang="ts"></script>

<script lang="ts" setup>
import ViewLabel from "@/components/view-label.vue";
import LikeLabel from "@/components/like-label.vue";
import CollectLabel from "@/components/collect-label.vue";

defineOptions({
  name: "document-item",
});

withDefaults(
  defineProps<{
    data: any;
  }>(),
  {
    data: () => ({}),
  }
);

const emits = defineEmits(["select"]);
</script>

<style lang="less">
.document-item {
  display: flex;
  padding: 26px;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: 0 0 10px 0 rgba(125, 125, 125, 0.1);
  border-radius: 20px;
  gap: 20px;
  &:not(:last-child) {
    margin-bottom: 20px;
  }
  &__content {
    width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    &-wrapped {
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    &-title {
      font-weight: 500;
      font-size: 28px;
      color: #000000;
      line-height: 40px;
      text-overflow: ellipsis;
      overflow: hidden;
      line-clamp: 2;
      -webkit-line-clamp: 2;
    }
    &-author {
      font-weight: 400;
      font-size: 20px;
      color: #8b8b8b;
      // line-height: 34px;
    }
    &-doc {
      font-weight: 400;
      font-size: 24px;
      color: #8b8b8b;
      line-height: 34px;

      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    &-operate {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        display: flex;
        align-items: center;
        gap: 20px;
      }
    }
  }
  .banner-wrapper {
    width: 252px;
    height: 194px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  &__banner {
    width: 252px;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: 0 auto;
  }
}
</style>
